/* google maps stuff */
var map_center;
var map_object = null;
var infowindow = null;
var infoBubble;
var places = [
				['Complesso Monumentale di S. Francesco', 40.71393, 14.93934, 4, '<div class="phoneytext">Complesso Monumentale di S. Francesco</div>'],
				['Sala Alberto Sordi', 40.71218, 14.94015, 4, '<div class="phoneytext">Sala Alberto Sordi</div>'],
				['Sala Truffaut', 40.71263, 14.94039, 4, '<div class="phoneytext">Sala Truffaut</div>'],
				['Aule Multimediali', 40.71244, 14.94067, 4, '<div class="phoneytext">Aule Multimediali</div>'],
				['Il Giardino degli Aranci', 40.71533, 14.94278, 4, '<div class="phoneytext">Il Giardino degli Aranci</div>'],
				];

function initializeGoogleMap(lat, lng)
	{
	map_center = new google.maps.LatLng(lat,lng);
	var mapOptions = {
		zoom: 16,
		center: map_center,
		mapTypeId: google.maps.MapTypeId.HYBRID
		};
	map_object = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
	//
	// places marker objects
	//
	setMarkers(map_object, places);
	infoBubble = new InfoBubble({
                content: '<div class="phoneytext">loading...</div>',
					 shadowStyle: 1,
					 padding: 0,
					 backgroundColor: 'rgb(57,57,57)',
					 borderRadius: 4,
					 arrowSize: 10,
					 borderWidth: 1,
					 borderColor: '#2c2c2c',
					 disableAutoPan: false,
					 hideCloseButton: true,
					 arrowPosition: 30,
					 backgroundClassName: 'phoney',
					 arrowStyle: 2
            });
	/*infowindow = new google.maps.InfoWindow({
                content: "loading..."
            });*/
				
	}
	
function setMarkers(map, markers)
	{
	for (var i = 0; i < markers.length; i++)
		{
		var sites = markers[i];
		var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
		var marker = new google.maps.Marker({
			position: siteLatLng,
			map: map,
			title: sites[0],
			zIndex: sites[3],
			html: sites[4]
			});
		//	
		var contentString = "Some content";
		//
		google.maps.event.addListener(marker, "click", function ()
			{
			//alert(this.html);
			infoBubble.setContent(this.html);
			infoBubble.open(map, this);
			//infowindow.setContent(this.html);
			//infowindow.open(map, this);
			});
		}
	}
	
/*function createMarker(lat, lng, text, map)
	{
	var markerpos = new google.maps.LatLng(lat, lng);
	var marker = new google.maps.Marker({
		position: markerpos,
		map: map,
		animation: google.maps.Animation.DROP
		});

	var boxText = document.createElement("div");
       //boxText.style.cssText = "border: 1px solid black; margin-top: 2px; background: black; padding: 2px; color: #EEE;";
       boxText.style.cssText = "background: black; color: #EEE; padding: 2px;";
       boxText.innerHTML = text;
                
	var ibOptions = {
		content: boxText
		,disableAutoPan: false
		,maxWidth: 0
		,pixelOffset: new google.maps.Size(0, 0)
		,zIndex: null
		,boxStyle: { 
			//background: "url('tipbox.gif') no-repeat",
			opacity: 0.70,
			width: "100px"
			}
		,closeBoxMargin: "10px 2px 2px 2px"
		,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
		,infoBoxClearance: new google.maps.Size(1, 1)
		,isHidden: false
		,pane: "floatPane"
		,enableEventPropagation: false
		};
	var ib = new InfoBox(ibOptions);

	google.maps.event.addListener(marker, 'click', function() {
		//infoWindow.open(map_object, marker);
		ib.open(map, marker);
		});
	}*/
	
	
function detectBrowser()
	{
	var useragent = navigator.userAgent;
	var mapdivMap = document.getElementById("map_canvas");

	//alert(useragent);
	mapdivMap.style.width = '400px';
	mapdivMap.style.height = '400px';
	/*if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 )
		{
		mapdivMap.style.width = '100%';
		mapdivMap.style.height = '100%';
		}
	else
		{
		mapdivMap.style.width = '600px';
		mapdivMap.style.height = '800px';
		}*/
	}
	
